<?php
/**
 * User: t.young
 * Date: 2017/12/20
 * Time: 15:52
 */

namespace backend\modules\system\controllers;


use backend\component\BackendBaseController;
use backend\service\AdminService;
use common\component\ClassFactory;
use common\models\permis\Task;

class MenuController extends BackendBaseController
{

    public function actions()
    {
        return [
            "modify" => [
                'class' => "backend\actions\ModifyAction",
                'modelName'=> Task::className()
            ],
            "delete" =>[
                'class' => "backend\actions\DeleteAction",
                'modelName'=>Task::className(),
                'is_physics' => true
            ],
        ];
    }

    /**
     * 加载菜单列表
     */
    public function actionList() {
        if (\Yii::$app->request->getIsAjax()) {
            return AdminService::MenuListData(\Yii::$app->request->post());
        }
        $model = new Task();
        return $this->render("list",['model'=>$model]);
    }

    public function actionEdit() {
        $id = \Yii::$app->request->get("id",0);
        $model = Task::modelById($id);
        $menuTree = AdminService::menuTree();
        return $this->render("edit",["model"=>$model,"menuTree"=>$menuTree]);
    }
}